package com.qinglian.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qinglian.entity.Like;
import com.qinglian.mapper.LikeListMapper;
import com.qinglian.service.ILikeListService;
import com.qinglian.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author augn
 * @since 2023-04-29
 */
@Service
public class LikeListServiceImpl extends ServiceImpl<LikeListMapper, Like> implements ILikeListService {

    @Autowired
    private LikeListMapper mapper;

    @Override
    public Result<?> addLike(Like like) {
        int insert = mapper.insert(like);
        return Result.success(insert);
    }

    @Override
    public Result<?> delLike(Integer findId, Integer userId) {

        QueryWrapper<Like> wrapper = new QueryWrapper<>();
        wrapper.eq("find_id",findId).eq("user_id",userId);
        int delete = mapper.delete(wrapper);
        return Result.success(delete);
    }
}
